import request from '@/utils/request'
import { AppThunk } from '@/store'
import { loginFormdata, LoginResponse } from '@/types/data'
import { setToken } from '../modules/login'
// 3. 异步action
export const asyncgetToken = (payload?: loginFormdata): AppThunk => {
  return async function async(dispatch, getState) {
    // dispatch(setToken())
    const res: LoginResponse = await request.post(
      '/authorizations',
      payload
    )
    dispatch(setToken(res.data))
  }
}